package com.tencent.sr.iris.basic.saas.restapi.group;

import com.tencent.sr.iris.activity.interfaces.request.group.AdvisorGroupTaskRequest;
import com.tencent.sr.iris.activity.interfaces.request.group.AdvisorGroupTaskSecondRequest;
import com.tencent.sr.iris.activity.interfaces.request.group.AdvisorGroupTaskThirdRequest;
import com.tencent.sr.iris.activity.interfaces.request.group.GroupTaskRequest;
import com.tencent.sr.iris.activity.interfaces.request.group.GroupTaskSecondRequest;
import com.tencent.sr.iris.basic.saas.common.enums.YesOrNoEnum;
import com.tencent.sr.iris.basic.saas.dependency.group.GroupTaskBoardDependency;
import com.tencent.sr.iris.basic.saas.service.group.ExportTaskService;
import com.tencent.sr.iris.basic.saas.interfaces.response.export.ExportResponse;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import com.tencent.sr.rmall.common.request.PaginationRequest;
import com.tencent.sr.rmall.springbootstarter.authtoken.localbean.AppUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Arrays;
import java.util.Objects;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Api(tags = "团长任务看板导出", value = "团长任务看板导出")
@RestController
@RequestMapping(value = {"/iris/activity/saas/v1/grouptask/board"})
public class GroupTaskBoardExportController {
    @Resource
    private ExportTaskService exportTaskService;
    @Resource
    private AppUser appUser;
    @Resource
    private GroupTaskBoardDependency groupTaskBoardDependency;

    @PostMapping("/export/groupTaskBoard")
    @ApiOperation(value = "团长任务列表导出")
    public HttpResult<ExportResponse> groupTaskBoard(
            @Validated @RequestBody PaginationRequest<GroupTaskRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        GroupTaskRequest groupTaskRequest = request.getQueryCriteria();
        groupTaskRequest.setUid(appUser.getUid());
        groupTaskRequest.setSaasId(appUser.getSaasId());
        groupTaskRequest.setIrisUid(Arrays.asList(appUser.getUid()));
        return HttpResult.succ(exportTaskService.groupTaskBoard(groupTaskRequest));
    }

    @PostMapping("/export/groupTaskBoardInvite")
    @ApiOperation(value = "团长任务列表(邀新有礼)导出")
    public HttpResult<ExportResponse> groupTaskBoardInvite(
            @Validated @RequestBody PaginationRequest<GroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setIrisUid(Arrays.asList(appUser.getUid()));
        return HttpResult.succ(exportTaskService.groupTaskBoardInvite(request.getQueryCriteria()));
    }

    @PostMapping("/export/groupTaskBoardFirstOrder")
    @ApiOperation(value = "团长任务列表(首单任务)导出")
    public HttpResult<ExportResponse> groupTaskBoardFirstOrder(
            @Validated @RequestBody PaginationRequest<GroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setIrisUid(Arrays.asList(appUser.getUid()));
        return HttpResult.succ(exportTaskService.groupTaskBoardFirstOrder(request.getQueryCriteria()));
    }

    @PostMapping("/export/groupTaskBoardSprint")
    @ApiOperation(value = "团长任务列表(GMV冲刺赛/销量冲刺赛)导出")
    public HttpResult<ExportResponse> groupTaskBoardSprint(
            @Validated @RequestBody PaginationRequest<GroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setIrisUid(Arrays.asList(appUser.getUid()));
        return HttpResult.succ(exportTaskService.groupTaskBoardSprint(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorGroupTaskBoard")
    @ApiOperation(value = "导师--团长任务列表导出")
    public HttpResult<ExportResponse> advisorGroupTaskBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        if (Objects.equals(request.getQueryCriteria().getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.getQueryCriteria().setAdviserId(appUser.getUid());
        }
        return HttpResult.succ(exportTaskService.advisorGroupTaskBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorInviteBoard")
    @ApiOperation(value = "导师--团长任务列表(邀新有礼)导出")
    public HttpResult<ExportResponse> advisorInviteBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        if (Objects.equals(request.getQueryCriteria().getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.getQueryCriteria().setAdviserId(appUser.getUid());
        }
        return HttpResult.succ(exportTaskService.advisorInviteBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorFirstOrderBoard")
    @ApiOperation(value = "导师--团长任务列表(首单任务)导出")
    public HttpResult<ExportResponse> advisorFirstOrderBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        if (Objects.equals(request.getQueryCriteria().getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.getQueryCriteria().setAdviserId(appUser.getUid());
        }
        return HttpResult.succ(exportTaskService.advisorFirstOrderBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorSprintBoard")
    @ApiOperation(value = "导师--团长任务列表(GMV冲刺赛/销量冲刺赛)导出")
    public HttpResult<ExportResponse> advisorSprintBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        if (Objects.equals(request.getQueryCriteria().getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.getQueryCriteria().setAdviserId(appUser.getUid());
        }
        return HttpResult.succ(exportTaskService.advisorSprintBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorCommissionBoard")
    @ApiOperation(value = "导师--团长任务列表(佣金回滚任务)导出")
    public HttpResult<ExportResponse> advisorCommissionBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        request.getQueryCriteria().setAdviserId(appUser.getUid());if (Objects.equals(request.getQueryCriteria().getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.getQueryCriteria().setAdviserId(appUser.getUid());
        }
        return HttpResult.succ(exportTaskService.advisorCommissionBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorInviteThirdBoard")
    @ApiOperation(value = "导师--三级页面团长任务列表(邀新有礼)导出")
    public HttpResult<ExportResponse> advisorInviteThirdBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskThirdRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setAdviserId(appUser.getUid());
        return HttpResult.succ(exportTaskService.advisorInviteThirdBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorFirstOrderThirdBoard")
    @ApiOperation(value = "导师--三级页面团长任务列表(首单任务)导出")
    public HttpResult<ExportResponse> advisorFirstOrderThirdBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskThirdRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setAdviserId(appUser.getUid());
        return HttpResult.succ(exportTaskService.advisorFirstOrderThirdBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorSprintThirdBoard")
    @ApiOperation(value = "导师--三级页面团长任务列表(GMV冲刺赛/销量冲刺赛)导出")
    public HttpResult<ExportResponse> advisorSprintThirdBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskThirdRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setAdviserId(appUser.getUid());
        return HttpResult.succ(exportTaskService.advisorSprintThirdBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorCommissionThirdBoard")
    @ApiOperation(value = "导师--三级页面团长任务列表(佣金回滚任务)导出")
    public HttpResult<ExportResponse> advisorCommissionThirdBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskThirdRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setAdviserId(appUser.getUid());
        return HttpResult.succ(exportTaskService.advisorCommissionThirdBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/groupNormalBoard")
    @ApiOperation(value = "团长--二级页面团长任务列表(普通团推团)导出")
    public HttpResult<ExportResponse> groupNormalBoard(
            @Validated @RequestBody PaginationRequest<GroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setIrisUid(Arrays.asList(appUser.getUid()));
        return HttpResult.succ(exportTaskService.groupNormalBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/groupSpecialBoard")
    @ApiOperation(value = "团长--二级页面团长任务列表(特邀团推团)导出")
    public HttpResult<ExportResponse> groupSpecialBoard(
            @Validated @RequestBody PaginationRequest<GroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setIrisUid(Arrays.asList(appUser.getUid()));
        return HttpResult.succ(exportTaskService.groupSpecialBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorNormalBoard")
    @ApiOperation(value = "导师--二级页面团长任务列表(普通团推团)导出")
    public HttpResult<ExportResponse> advisorNormalBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        if (Objects.equals(request.getQueryCriteria().getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.getQueryCriteria().setAdviserId(appUser.getUid());
        }
        return HttpResult.succ(exportTaskService.advisorNormalBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorSpecialBoard")
    @ApiOperation(value = "导师--二级页面团长任务列表(特邀团推团)导出")
    public HttpResult<ExportResponse> advisorSpecialBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        if (Objects.equals(request.getQueryCriteria().getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.getQueryCriteria().setAdviserId(appUser.getUid());
        }
        return HttpResult.succ(exportTaskService.advisorSpecialBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorNormalBoardThird")
    @ApiOperation(value = "导师--三级页面团长任务列表(普通团推团)导出")
    public HttpResult<ExportResponse> advisorNormalBoardThird(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskThirdRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setAdviserId(appUser.getUid());
        return HttpResult.succ(exportTaskService.advisorNormalBoardThird(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorSpecialBoardThird")
    @ApiOperation(value = "导师--三级页面团长任务列表(特邀团推团)导出")
    public HttpResult<ExportResponse> advisorSpecialBoardThird(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskThirdRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setAdviserId(appUser.getUid());
        return HttpResult.succ(exportTaskService.advisorSpecialBoardThird(request.getQueryCriteria()));
    }



    @PostMapping("/export/groupTaskRank")
    @ApiOperation(value = "团长--二级页面团长任务列表(排行榜)导出")
    public HttpResult<ExportResponse> groupTaskRank(
            @Validated @RequestBody PaginationRequest<GroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        return HttpResult.succ(exportTaskService.groupTaskRank(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorRankBoard")
    @ApiOperation(value = "导师--二级页面团长任务列表(排行榜)导出")
    public HttpResult<ExportResponse> advisorRankBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        if (Objects.equals(request.getQueryCriteria().getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.getQueryCriteria().setAdviserId(appUser.getUid());
        }
        return HttpResult.succ(exportTaskService.advisorRankBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorRankBoardThird")
    @ApiOperation(value = "导师--三级页面团长任务列表(排行榜)导出")
    public HttpResult<ExportResponse> advisorRankBoardThird(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskThirdRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setAdviserId(appUser.getUid());
        return HttpResult.succ(exportTaskService.advisorRankBoardThird(request.getQueryCriteria()));
    }

    @PostMapping("/export/groupSpecialSprintBoard")
    @ApiOperation(value = "团长--二级页面团长任务列表(特邀会员冲刺赛)导出")
    public HttpResult<ExportResponse> groupSpecialSprintBoard(
            @Validated @RequestBody PaginationRequest<GroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        return HttpResult.succ(exportTaskService.groupSpecialSprintBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorSpecialSprintBoard")
    @ApiOperation(value = "导师--二级页面团长任务列表(特邀会员冲刺赛)导出")
    public HttpResult<ExportResponse> advisorSpecialSprintBoard(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskSecondRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        if (Objects.equals(request.getQueryCriteria().getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.getQueryCriteria().setAdviserId(appUser.getUid());
        }
        return HttpResult.succ(exportTaskService.advisorSpecialSprintBoard(request.getQueryCriteria()));
    }

    @PostMapping("/export/advisorSpecialSprintBoardThird")
    @ApiOperation(value = "导师--三级页面团长任务列表(特邀会员冲刺赛)导出")
    public HttpResult<ExportResponse> advisorSpecialSprintBoardThird(
            @Validated @RequestBody PaginationRequest<AdvisorGroupTaskThirdRequest> request) {
        if (Objects.isNull(request)) {
            request = new PaginationRequest();
        }
        request.getQueryCriteria().setUid(appUser.getUid());
        request.getQueryCriteria().setSaasId(appUser.getSaasId());
        //request.getQueryCriteria().setAdviserId(appUser.getUid());
        return HttpResult.succ(exportTaskService.advisorSpecialSprintBoardThird(request.getQueryCriteria()));
    }


}
